package com.example.cherrytest;


import cn.cherry.core.exception.BusinessException;
import cn.cherry.excel.util.ExcelUtils;
import cn.cherry.excel.util.SysCountryExcelVO;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class ExcelTestDemon {

    @Test
    public  void get_excel_list() {
        try (InputStream inputStream = new ClassPathResource("country1721719167990.xlsx").getInputStream()) {
            List<SysCountryExcelVO> read = ExcelUtils.read(inputStream, SysCountryExcelVO.class);

            log.error("excel>>list:{}", JSON.toJSON(read));
        } catch (IOException e) {
            log.error("文件读取异常：{}", e.getMessage());
            throw new BusinessException("文件读取异常");
        }
    }


}
